package gtkwire.widget;

import gtkwire.listener.connector.ButtonListenerFilter;
import gtkwire.listener.ButtonListener;
import gtkwire.*;

/**
*A widget that creates a signal when clicked on.
*Documentation for this class is from the gtk+ .c file that this class binds to. See original file for copyrights.
*/
public class GtkButton extends GtkBin
{
	public GtkButton( String label )
	{
		super();
		widgetType = WT_GtkButton;
		gtkCreate();
		setLabel( label );
	}

	public GtkButton()
	{
		super();
		widgetType = WT_GtkButton;
		gtkCreate();
	}

	public GtkButton( String name, GladeKey key )
	{
		super( name, key );
		widgetType = WT_GtkButton;
	}
	/**
	*Sets the text of the label of the button.
	*This text is also used to select the stock item if gtk_button_set_use_stock() is used(not implemented)
	*/
	public void setLabel( String label )
	{
		app().sendCommand( name, GTKWireCommand.SET_LABEL, label );
	}
	/**
	*If true, an underline in the text of the button label indicates the next character should be used for the mnemonic accelerator key.
	*/
	public void setUseUnderline( boolean b )
	{
		app().sendCommand( name, GTKWireCommand.SET_USE_UNDERLINE, b );
	}
	/**
	*Sets whether the button will grab focus when it is clicked with the mouse.
	*/
	public void setFocusOnClick( boolean b )
	{
		app().sendCommand( name, GTKWireCommand.SET_FOCUS_ON_CLICK, b );
	}
	/**
	*If TRUE, the label set on the button is used as a stock id to select the stock item for the button.
	*/
	public void setUseStock( boolean b )
	{
		app().sendCommand( name, GTKWireCommand.SET_STOCK, b );
	}

	/**
	* Set the image of button to the given widget.
	*/
	public void setImage( GtkImage img )
	{
		app().sendCommand( name, GTKWireCommand.SET_IMAGE, img.getName());
	}

	/**
	*Adds button listener.
	*/
	public void addButtonListener( ButtonListener listener )
	{
		ButtonListenerFilter bl = new ButtonListenerFilter( listener );
		bl.addFilteringName( name );
		app().addListener( bl );
		connectSignals( bl.getSignals() );
	}

}//end class